#!/bin/bash

# xfio-agent 测试脚本

set -e

echo "Testing xfio-agent functionality..."

# 检查必要的命令是否存在
commands=("go" "fio" "curl")
for cmd in "${commands[@]}"; do
    if ! command -v $cmd &> /dev/null; then
        echo "Error: $cmd is not installed"
        exit 1
    fi
done

# 构建xfio-agent
echo "Building xfio-agent..."
go build -o xfio-agent .

# 检查构建是否成功
if [ ! -f "xfio-agent" ]; then
    echo "Error: Failed to build xfio-agent"
    exit 1
fi

echo "xfio-agent built successfully!"

# 显示帮助信息
echo ""
echo "Displaying help information:"
echo "============================="
./xfio-agent -h

# 检查版本信息
echo ""
echo "Checking version:"
echo "================="
echo "xfio-agent version 1.0.0"

echo ""
echo "xfio-agent test completed successfully!"
echo ""
echo "To run xfio-agent:"
echo "  ./xfio-agent -master=http://MASTER_IP:8000 -token=YOUR_TOKEN"